﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControls_ThuatToan_TimKiem : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void btn_Run_Click(object sender, EventArgs e)
    {
        try
        {
            string arrinput = txt_ArrInput.Text;
            arrinput = arrinput.Substring(1);
            arrinput = arrinput.Substring(0, arrinput.Length - 2);

            string valueinput = txt_ValueInput.Text.Trim();
            
            String[] strarrinput = arrinput.Split(',');

            txt_Output.Text = "Không tìm thấy";

            for (int i = 0; i < strarrinput.Length; i++)
            {
                if (strarrinput[i].Trim() == valueinput)
                {
                    txt_Output.Text = i.ToString();
                    break;
                }
            }
            

            lbl_MessageResult.Text = "Done!";
        }
        catch (Exception)
        {
            lbl_MessageResult.Text = "Lỗi input hoặc lỗi trong quá trình thực thi, hãy kiểm tra lại dữ liệu";
        }
        
    }
}